package com.woniu.smallmedical.controller;

import com.woniu.smallmedical.entity.Address;
import com.woniu.smallmedical.entity.ResponseResult;
import com.woniu.smallmedical.server.AddressServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class AddressController {
    @Autowired
    AddressServer addressServer;
    //查询省
    @GetMapping("/getprovince")
    public ResponseResult getAdderss(){
        System.out.println("查询所有省！！！！");
        //省
        List<Address> province = addressServer.getProvince();
        return new ResponseResult(province,200,"所有省信息");
    }
    //查询市
    @GetMapping("/getCity/{id}")
    public ResponseResult getCity(@PathVariable int id){
        System.out.println("查询省对应的市！！！！");
        //市
        List<Address> getcity = addressServer.getcity(id);
        return new ResponseResult(getcity,200,"省对应的市信息");
    }
}
